<template>
	<view class="pass_container">
		<view class="my_box">
			<view class="my_box_box">
				<view class="my_box_top" v-for="(item, index) in btnList" :key="index" @click="jumpSwitch(item.btnName)">
					<view class="avatoa">
						<image :src="item.btnImg" class="imgava"></image>
						<text class="my_txt">{{item.btnName}}</text>
					</view>
					<text class="my_txt mytxt">></text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				btnList: [
					{ btnName: '支付密码设置', btnImg: '../../static/images/denglumima.png' },
					{ btnName: '支付密码重置', btnImg: '../../static/images/denglumima.png' }
				],
				memberInfo: {},
				bizUserId: ''
			}
		},
		onShow:function(){
			this._getIndividualMemberInfo()
		},
		methods: {
			jumpSwitch(name) {
				let bizUserId = uni.getStorageSync('bizUserId')
				if(name == '支付密码设置') {
					uni.request({
						method: 'POST',
						url: 'https://wlreaohs.xiaomy.net/common/biz/cloud/member/setPayPwd',
						data: {
							bizUserId: bizUserId,
							phone: this.memberInfo.phone,
							name: this.memberInfo.name,
							identityNo: this.memberInfo.identityCardNo
						},
						header: { 'content-type': 'application/json' },
						success: (res) => {
							console.log(res)
							if(res.data.code == 0) {
								uni.navigateTo({
									url: './toPass?url=' + encodeURIComponent(res.data.data.url)
								})
							} else {
								uni.showModal({
									title: '温馨提示',
									content: `${res.data.msg}`,
									showCancel:false
								})
							}
						},
						fail: (err) => {
							uni.hideLoading()
							console.log(err)
						}
					})
				}
				if(name == '支付密码重置') {
					uni.request({
						method: 'POST',
						url: 'https://wlreaohs.xiaomy.net/common/biz/cloud/member/resetPayPwd',
						data: {
							bizUserId: bizUserId,
							phone: this.memberInfo.phone,
							name: this.memberInfo.name,
							identityNo: this.memberInfo.identityCardNo
						},
						header: { 'content-type': 'application/json' },
						success: (res) => {
							console.log(res)
							if(res.data.code == 0) {
								uni.navigateTo({
									url: './toPass?url=' + encodeURIComponent(res.data.data.url)
								})
							} else {
								uni.showModal({
									title: '温馨提示',
									content: `${res.data.msg}`,
									showCancel:false
								})
							}
						},
						fail: (err) => {
							uni.hideLoading()
							console.log(err)
						}
					})
				}
			},
			_getIndividualMemberInfo() {
				let bizUserId = uni.getStorageSync('bizUserId')
				uni.request({
					method: 'POST',
					url: 'https://wlreaohs.xiaomy.net/common/biz/cloud/member/getIndividualMemberInfo',
					data: {
						bizUserId: bizUserId
					},
					header: { 'content-type': 'application/json' },
					success: (res) => {
						console.log(res)
						if(res.data.code == 0) {
							this.memberInfo = res.data.data.memberInfo
							this.bizUserId = res.data.data.bizUserId
						}
					},
					fail: (err) => {
						uni.hideLoading()
						console.log(err)
					}
				})
			},
		}
	}
</script>

<style>
	.pass_container {
		height: 100vh;
		background-color: rgb(243, 243, 243);
		overflow: hidden;
	}
	.my_box {
		margin: 30rpx 0 0 0;
		padding: 0 30rpx;
	}
	.my_box_box {
		display: flex;
		flex-direction: column;
	}
	.my_box_top {
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
		padding: 20rpx;
		border-radius: 10rpx;
		background-color: #FFFFFF;
		margin-bottom: 20rpx;
	}
	.my_box_top:last-child {
		margin-bottom: 0;
	}
	.imgava {
		width: 40rpx;
		height: 40rpx; 
		margin-right: 15rpx;
	}
	.avatoa {
		display: flex;
		align-items: center;
	}
	.my_txt {
		font-family: PingFangSC;
		font-weight: 400;
		font-size: 30rpx;
		color: #000000;
	}
	.mytxt {
		color: rgb(199, 199, 204);
	}
</style>
